<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <title>Title</title>
</head>
<body>
<div id="app">

    <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="活动名称">
            <el-input v-model="form.username"></el-input>
        </el-form-item>
        <el-form-item label="活动名称">
            <el-input type="password" v-model="form.password"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="logIn">立即创建</el-button>
        </el-form-item>
    </el-form>
</div>
<!--<script th:src="@{/js/vue.js}"></script>-->
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
    var vm=new Vue({
        el:"#app",
        data:{
            name:"mcy",
            form: {
                username: '',
                password: '',
            }
        },
        methods:{
            logIn:function (){
                var that=this;
                axios.get('/user/login', {
                    params: {
                        username: that.form.username,
                        password: that.form.password
                    }
                }).then(function (response) {
                        console.log(response);
                        if(response.data=="ok"){
                            window.location.href="dashboard"
                        }else{
                            that.$message(response.data);
                        }
                    })
                    .catch(function (error) {
                        that.$message(error);
                    });
            },
        }
    })
</script>
</body>
</html>
